<?php
namespace app\controllers;

use app\common\corelib\CacheHelper;
use app\logic\ShopLogic;
use Yii;


class ShopController extends BaseController
{

    const LIMIT = 10;

    /**
     * 商品详情
     * @apiDescription   by Jim
     * @api              {post} /shop/goods-detail 商品详情
     * @apiName          goods-detail
     * @apiVersion       1.0.0
     * @apiParam {int} goods_id
     * @apiGroup         Shop
     * @apiSampleRequest /shop/goods-detail?flagsign=1
     * @apiSuccessExample {json} 获取成功
     * {
        "goods_descpic": "http://fdsfs", // 商品图片， 带http
        "shipping_fee": 0.00, //邮费
        "goods_name": "fdsafsafsa", // 商品名
        "market_price": 128.00, // 原价
        "real_price": 100.00, // 折扣价
        "goods_desc": "dsafasfsa", // 商品详情
        "need_idcard":0      //该商品购买时是否需要填写身份证信息，0是不需要，1是需要
    }
     * @apiError         300000    获取失败
     */
    public function actionGoodsDetail(){
        $goods_id = $this->getQueryparams('goods_id',1);
        $shopLogic = new ShopLogic();
        $result = $shopLogic->getGoods($goods_id);
        $this->response($result);
    }

    /**
     * 查看门店
     * @apiDescription   by Jim
     * @api              {post} /shop/store 查看门店
     * @apiName          store
     * @apiVersion       1.0.0
     * @apiParam {int} goods_id
     * @apiParam {string} area_code 区域code -1为不限区域
     * @apiParam {string} keyword   搜索关键词
     * @apiGroup         Shop
     * @apiSampleRequest /shop/store?flagsign=1
     * @apiSuccessExample {json} 获取成功
     * [{
    "store_name": "fdsafsafsa", // 店名
    "province":"**省",
    "city":"**市",
    "district":"**区",
    "address": "机场路219号", // 地址，因为省市区和具体地址分行显示，所以我分开传输给你
    }]
     * @apiError         300000    获取失败
     */
    public function actionStore(){
        $goods_id = $this->getQueryparams('goods_id',1);
        $area_code = $this->getQueryparams('area_code','-1');
        $region_level = $this->getQueryparams('region_level',0);
        $keyword = $this->getQueryparams('keyword','');
        $shopLogic = new ShopLogic();
        $result = $shopLogic->getStore($goods_id,$area_code,$region_level,$keyword);
        $this->response($result);
    }

}